<template>
  <div
    style="width: 100%; height: 100%; position: relative"
    @mouseover="showHover = item.id"
    @mouseout="showHover = null"
    class="contain"
  >
    <!-- 武将 -->
    <div style="width: 100%; height: 100%">
      <div class="top">
        <div class="name">{{ item.name }}</div>
        <div class="cost">{{ item.salary }}</div>
      </div>
      <div class="mid">
        <div class="image">
          <van-icon
            class="iconFont"
            class-prefix="icon"
            size="100"
            :class="item.image"
          />
        </div>
        <div class="ablity">
          <div>{{ item.pow }}</div>
          <div>{{ item.int }}</div>
        </div>
      </div>
      <div class="bottom">
        <div v-show="item.tactic_name">战法：{{ item.tactic_name }}</div>
        <div v-show="item.stratagem_name">计谋：{{ item.stratagem_name }}</div>
        <div v-show="item.politics_name">政策：{{ item.politics_name }}</div>
      </div>
    </div>
    <!-- 武将-悬浮内容 -->
    <div
      v-show="showHover == item.id"
      :style="{
        left: index % 5 == 4 ? '-70%' : '70%',
      }"
      class="map-hover"
    >
      <div class="row" v-show="item.pow">
        <span class="title">主帅：</span>出战武将【武力】+{{
          Math.floor(item.pow / 10)
        }}
        <br />（{{ item.pow + "/ 10" }}）
      </div>
      <!-- <div class="row" v-show="item.int">
        <span class="title"> 军师：</span>
        税收+{{ item.int * 1000 }} <br />（{{ item.int + "* 1000" }}）
      </div> -->
    </div>
    <van-icon
      class="iconFont water"
      class-prefix="icon"
      size="100"
      :class="`icon-${item.type}`"
    />
  </div>
</template>
<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => {
        return {
          id: 999,
          name: "稻草人",
          type: "normal",
          pow: 1,
          int: 1,
          salary: 50,
          tactic_name: "恐惧",
          stratagem_name: "夜割",
          politics_name: "群鸦风暴",
        };
      },
    },
    index: {
      type: Number,
      default: null,
    },
  },
  mounted() {},
  data() {
    return {
      showHover: 314159,
    };
  },
  methods: {
    getInfo(value) {
      let res = value.split(";");
      return res;
    },
  },
};
</script>
<style lang="less" scoped>
.contain {
  background-color: #fff;
  border-radius: 10px;
}
.water {
  position: absolute;
  right: 0;
  bottom: 10px;
  opacity: 0.5;
}
.top {
  height: 15%;
  border: 2px solid #000000;
  border-top-right-radius: 6px;
  border-top-left-radius: 6px;
  display: flex;
  justify-content: space-between;
  .name {
    flex: 1;
  }
  .cost {
    display: inline-block;
    border-left: 2px solid #000000;
    align-self: center;
    min-width: 60px;
    padding: 0 5px;
  }
}
.mid {
  height: 35%;
  border: 2px solid #000000;
  text-align: start;
  display: flex;
  padding: 10px 0 10px 10px;
  .ablity {
    font-size: 50px;
    font-weight: bolder;
    padding: 0 0 0 20px;
    text-align: center;
  }
}
.bottom {
  text-align: start;
  height: calc(50% - 50px);
  border: 2px solid #000000;
  padding: 10px;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;

  font-size: 20px;
}
.map-hover {
  border: 2px solid #737373;
  position: absolute;
  background-color: #ffffff;
  z-index: 9999;
  width: 100%;
  min-height: 40%;
  top: 70%;
  border-radius: 6px;
  text-align: start;
  padding: 10px;

  font-size: 16px;
  .row {
    padding-bottom: 10px;
    .title {
      font-weight: bolder;
    }
  }
  .row + .row {
    border-top: 0.2px solid #b0b0b0;
    padding-top: 10px;
  }
}

.map-hover::-webkit-scrollbar {
  display: none;
}
</style>
